package com.wechat.android.app.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wechat.android.app.R;
import com.wechat.android.app.entity.GetFriendRequestModel;
import com.wechat.android.app.utils.glide.GlideUtils;

import java.util.List;

/**
 * Created by yang on 2017/12/4.
 */

public class NewFriendAdapter extends BaseQuickAdapter<GetFriendRequestModel, BaseViewHolder> {
    private OnAddFriendsListener onAddFriend;

    public NewFriendAdapter(int layoutResId, @Nullable List<GetFriendRequestModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, final GetFriendRequestModel data) {
        ImageView avatar = (ImageView) holder.getView(R.id.avatar);
        TextView name = (TextView) holder.getView(R.id.name);
        TextView indicator = (TextView) holder.getView(R.id.indicator);
        name.setText(data.getName());
        GlideUtils.loadImage(mContext, data.getLogo(), avatar, new GlideUtils.ImageLoadListener<String, GlideDrawable>() {
            @Override
            public void onLoadingComplete(String uri, ImageView view, GlideDrawable resource) {

            }

            @Override
            public void onLoadingError(String source, Exception e) {

            }
        }, R.mipmap.em_default_avatar, R.mipmap.em_default_avatar);
        indicator.setText("\uD81B\uDF0A\uD81B\uDF51\uD81B\uDFC4\uD81B\uDFC0\uD81B\uDF3B\uD81B\uDFD4\uD81B\uDF3D\uD81B\uDFD3\uD81B\uDF16\uD81B\uDF54");
        indicator.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onAddFriend != null) {
                    onAddFriend.getAddFriendOnClick(data);
                }
            }
        });
    }

    public interface OnAddFriendsListener {
        void getAddFriendOnClick(GetFriendRequestModel data);
    }

    public void setAddFriendOnClick(OnAddFriendsListener onAddFriend) {
        this.onAddFriend = onAddFriend;
    }

}